<?php

use yii\helpers\Url;

$this->title = '优惠券';
?>

<!-- <header class="header">优惠券</header> -->
<header class="header">
<a href="<?= Url::to(['member/index']) ?>">
    <i class="back-icon"></i>返回
</a>
</header>

<?php if ($coupons) { ?>

<div class="page-bd" id="coupons_con">

    <!-- 加载方式需要和PHP商议 -->
    <!-- <div class="weui-loadmore">
        <i class="weui-loading"></i>
        <span class="weui-loadmore__tips">正在加载</span>
    </div> -->

    <ul id='couponsList'>
        <?php foreach ($coupons as $coupon) { ?>
        <li class="">
            <div class="weui-flex js-category">
                <div class="weui-flex-item">
                    <div class="weui_panel">
                        <div class="weui_panel_bd">
                            <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg">
                                <div class="weui_media_hd">
                                    <img src="<?= Url::to('@web/member/img/coupons.png', true)?>" class="weui_media_appmsg_thumb leftImg" alt="">
                                </div>
                                <div class="weui_media_bd">
                                    <h4 class="weui_media_title couponTitle">
                                        <?= isset($coupon['detail']['name']) ? $coupon['detail']['name'] : '' ?>
                                    </h4>
                                    <p class="weui_media_desc couponKind">
                                        <?= isset($coupon['detail']['type']) ? ($coupon['detail']['type'] == 'cash' ? '现金券' : '折扣券') : '' ?>
                                    </p>
                                    <p class="weui_media_desc couponUsage">
                                        <?= isset($coupon['detail']['description']) ? $coupon['detail']['description'] : '饮品立减10元' ?>
                                    </p>
                                </div>
                                <!-- <div class="couponStatus">
                                    <?= isset($coupon['status']) ? ($coupon['status'] == 1 ? '未使用' : '已使用') : '' ?>
                                </div> -->
                            </a>
                        </div>
                    </div>
                </div>
                <i class="icon icon-74"></i>
            </div>
            <div class="page-category js-categoryInner">
                <div class="weui_cells">
                    <?php if (!empty($coupon['coupon_code'])) { ?>
                        <div class="weui_cell barCard">
                            <img src="<?= Url::to('@web/member/codemaker/barcode.php?text=' . $coupon['coupon_code'], true) ?>">
                        </div>
                    <?php } ?>
                    <div class="weui_cell">
                        <div class="weui_cell_bd weui_cell_primary">
                            <p>优惠券号</p>
                        </div>
                        <div class="weui_cell_ft waringColor">
                            <?= isset($coupon['coupon_code']) ? $coupon['coupon_code'] : '' ?>
                        </div>
                    </div>
                    <div class="weui_cell">
                        <div class="weui_cell_bd weui_cell_primary">
                            <p>活动日期</p>
                        </div>
                        <div class="weui_cell_ft waringColor">
                            <?= isset($coupon['start_date']) ? (substr($coupon['detail']['start_date'], 0, 10) . '~' . substr($coupon['detail']['end_date'], 0, 10)) : '' ?>
                        </div>
                    </div>
                    <div class="weui_cell">
                        <div class="weui_cell_bd weui_cell_primary">
                            <p>使用说明</p>
                        </div>
                        <div class="weui_cell_ft waringColor">
                            一经使用，概不退换<br>
                            绵阳地区会员专享
                        </div>
                    </div>
                    <!-- <div class="weui_cell">
                        <div class="weui_cell_bd weui_cell_primary">
                            <p>使用状态</p>
                        </div>
                        <div class="weui_cell_ft waringColor">
                            <?= isset($coupon['status']) ? ($coupon['status'] == 1 ? '未使用' : '已使用') : '' ?>
                        </div>
                    </div> -->
                </div>
            </div>
        </li>
        <?php } ?>
    </ul>
</div>

<?php } else { ?>
    <header class="header">您还没有优惠券</header>
<?php } ?>